<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Usersauthority extends Model
{
    protected $table = 'users_authority';
    protected $primaryKey = 'id';

    public static function createUsersAuthority($users_id,$miniapp_style,$miniapp_third)
    {
        return self::insert([
            'users_id'   => $users_id,
            'miniapp_style'      => $miniapp_style,
            'miniapp_third'   => $miniapp_third,
            'created_at' => time(),
        ]);
    }

    public static function updateUsersAuthority($users_id,$miniapp_style,$miniapp_third,$miniapp_publish,$api_token,$api_urlscheme,$third_api,$lists_htmls)
    {
        return self::where("users_id",$users_id)->update(["miniapp_style"=>$miniapp_style,"miniapp_third"=>$miniapp_third,"miniapp_publish"=>$miniapp_publish,"api_token"=>$api_token,"api_urlscheme"=>$api_urlscheme,"third_api"=>$third_api,"lists_htmls"=>$lists_htmls]);
    }

    public static function getUsersAuthority($users_id)
    {
        return self::where("users_id",$users_id)->orderBy("id","DESC")->first();
    }
}
